<%--
  Created by IntelliJ IDEA.
  User: 23050
  Date: 2023/9/23
  Time: 10:53
  To change this template use File | Settings | File Templates.
--%>

<%--num.jsp--%>
<%@ page language="java" contentType="text/html;
charset=UTF-8" pageEncoding="UTF-8" %>


<!DOCTYPE html>
<html>
<head>
    <title>乘法表</title>
</head>

<body>
<%
    String numberStr = request.getParameter("number");
    int number = 0;
    try{
        number = Integer.parseInt(numberStr);
        if (number < 1 || number > 20) {
            request.setAttribute("message","请输入1-20的整数");
            request.getRequestDispatcher("index.jsp").forward(request,response);
        }
    }catch (Exception e){
        request.setAttribute("message","请输入1-20的整数");
        request.getRequestDispatcher("index.jsp").forward(request,response);
    }

%>

<table>
    <%
        for(int i = 1;i<=number;i++){
            for(int j = 1;j<=i;j++){
                out.print(j+"*"+i+"="+j*i+"&nbsp&nbsp");
            }
            out.print("<br>");
        }

    %>
</table>
</body>
</html>
